﻿using iMES.Calendar.Services;
using iMES.Entity.DomainModels;
using iMES.System.IServices;
using iMES.WorkManShip.IRepositories;
using iMES.WorkManShip.IServices;
using iMES.WorkManShip.Services;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;

namespace iMES.WebApi.Controllers
{
    public partial class ExceptionHandlingController
    {
        private readonly IWM_ExceptionService _service;//访问业务代码
        private readonly ITeam_UserService team_User;
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IWM_TeamMebRepositories _teamMemberRepository;
        [ActivatorUtilitiesConstructor]
        public ExceptionHandlingController(IWM_ExceptionService service, IHttpContextAccessor httpContextAccessor, IWM_TeamMebRepositories teamMemberRepository, ITeam_UserService team_User) : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
            _teamMemberRepository = teamMemberRepository;
            this.team_User = team_User;
        }
        /// <summary>
        /// 获取班组下面的班组成员
        /// </summary>
        /// <param name="TeamId">班组主键</param>
        /// <returns></returns>
        [Route("getTeamMembers"), HttpGet]
        public async Task<IActionResult> GetTeamMembers(int TeamId)
        {
            var rows = await _teamMemberRepository.FindAsIQueryable(x => x.Id == TeamId)
                  .ToListAsync();
            return JsonNormal(rows);
        }
        /// <summary>
        /// 新用户表
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        [HttpPost, Route("getTeamUser")]
        public IActionResult getTeamUser([FromBody] PageDataOptions options)
        {
            //1.可以直接调用框架的GetPageData查询
            PageGridData<Team_User> data = Team_UserService.Instance.GetPageData(options);
            return JsonNormal(data);
        }
        /// <summary>
        /// 排班计划
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        [HttpPost, Route("getPlan")]
        public IActionResult getPlan([FromBody] PageDataOptions options)
        {
            //1.可以直接调用框架的GetPageData查询
            PageGridData<Team_Planning> data = Team_PlanService.Instance.GetPageData(options);
            return JsonNormal(data);
        }
    }
}
